package com.ex.himoffice.Controller;

import java.awt.List;
import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ex.himoffice.Service.QnaService;
import com.ex.himoffice.Vo.QnaVo;

@WebServlet("*.qna")
public class QnaController extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = -4122563455240882016L;

	

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.service(req, res);
		System.out.println("Controller ");
		
		RequestDispatcher dispatch = null;
		QnaService service = new QnaService();
		QnaVo param = new QnaVo();
		
		String cmd = req.getParameter("cmd");
		
		if(cmd.equals("insert")){
			int succ = 0;
			System.out.println("cmd : "+cmd);
			param.setSSO_ID(req.getParameter("SSO_ID"));
			param.setTITLE(req.getParameter("TITLE"));
			param.setCONTENT(req.getParameter("CONTENT"));
			
			succ = service.qnaInsert(param);
			dispatch = req.getRequestDispatcher("/WEB-INF/views/qna/list.jsp");
			
//			HttpResponse.sendMessage(res, Integer.toString(succ));
		}
		else if(cmd.equals("list")){
			System.out.println("cmd : "+cmd);
			ArrayList<QnaVo> qnaList = service.list(param);
			
		}
		
		
	}

	


}
